package com.zhong.tree;

/**
 * @author zhong
 * @version 1
 * @date 2022/04/09
 * @contact 1478168700@qq.com
 **/
public final class TreeNodeBuilder {
    private String data;
    private TreeNode left;
    private TreeNode right;

    private TreeNodeBuilder() {
    }

    public static TreeNodeBuilder aTreeNode() {
        return new TreeNodeBuilder();
    }

    public TreeNodeBuilder withData(String data) {
        this.data = data;
        return this;
    }

    public TreeNodeBuilder withLeft(TreeNode left) {
        this.left = left;
        return this;
    }

    public TreeNodeBuilder withRight(TreeNode right) {
        this.right = right;
        return this;
    }

    public TreeNode build() {
        TreeNode treeNode = new TreeNode();
        treeNode.setData(data);
        treeNode.setLeft(left);
        treeNode.setRight(right);
        return treeNode;
    }
}
